home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / DLGDEMO.AML < prev    next >
Text File  |  1996-07-17  |  3KB  |  131 lines

  1. //--------------------------------------------------------------------
  2. // DLGDEMO.AML
  3. // Dialog Box Demo, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro displays a sample dialog box with the following items:
  6. //
  7. //   - Listbox
  8. //   - Edit Fields
  9. //   - Checkboxes
  10. //   - Radio Buttons
  11. //   - Pushbuttons
  12. //   - Background Text
  13. //
  14. // Usage:
  15. //
  16. // Select this macro from the Macro List (on the Macro menu), or run it
  17. // from the macro picklist <shift f12>.
  18. //--------------------------------------------------------------------
  19.  
  20. include bootpath "define.aml"
  21.  
  22. variable control1, control2, control3, control4, control5
  23.  
  24. // main dialog box
  25. dialog "Dialog Box Demo" 69 15 "c"
  26.  
  27. // write background text on the dialog box
  28. gotoxy 52 13
  29. writestr "Back"
  30. writestr "ground"     (color magenta     on gray)
  31. writestr " Text"      (color brightred   on gray)
  32. gotoxy 53 14
  33. writestr "of"         (color yellow      on gray)
  34. writestr " any"       (color brightgreen on gray)
  35. writestr " color"     (color brightblue  on gray)
  36.  
  37. // control #1: listbox
  38. filespec = bootpath "macro\\*.aml"
  39. listbox "&Listbox:" 3 2 (loadbuf filespec '' '' 'f' +
  40.                                  (sub '[~lc]' '' _NameStyle 'x'))
  41.         16 12
  42. fmgr.fsort 'n'
  43. whenenter "listenter"
  44. function listenter
  45.   msgbox "You selected:  " + (onname (fmgr.fgetfile))
  46. end
  47.  
  48. // control #2: edit field
  49. field "&Edit Field 1: >"  21  3 14 "string"
  50.  
  51. // control #3: edit field
  52. field "Edit &Field 2:"    21  5 28 (onname "file.txt") "_load"
  53.  
  54. // control #4: check boxes
  55. groupbox 'Check Boxes:' 52 2
  56.   (menu ''
  57.      item " [ ] &Apples"
  58.      item " [ ] &Oranges"
  59.      item " [ ] &Melons"
  60.      item " [ ] &Bananas"
  61.    end) 15 'am' 'aomb'
  62. whenselect "checkbox"
  63. function checkbox
  64.   beep (if? (getchar 3) == 'X' 430 107) 90
  65. end
  66.  
  67. // control #5: radio buttons
  68. groupbox 'Radio Buttons: ' 52 8
  69.   (menu ''
  70.      item " ( ) &Yes"
  71.      item " ( ) &No"
  72.      item " ( ) &Maybe"
  73.    end) '' 'y' 'yno'
  74. whenselect "radio"
  75. function radio
  76.   line = getrow
  77.   if line == 3 then
  78.     beep 430 45
  79.     beep 107 45
  80.   else
  81.     beep (if? line == 1 430 107) 90
  82.   end
  83. end
  84.  
  85. // controls #6,#7: ok/cancel buttons
  86. button "O&k"    23  9 8
  87. button "Cancel" 23 11 8
  88.  
  89. // control #8: long button
  90. button "Long &Button" 21 14 28
  91. whenenter "longbutton"
  92. function longbutton
  93.   beep 215 100
  94. end
  95.  
  96. // control #9: big button
  97. button "" 35 8 14 5
  98. writestr "Big Button" (color black on green) 3 3
  99. whenenter "bigbutton"
  100. function bigbutton
  101.   beep  60 70
  102. end
  103.  
  104. macrofile = arg 1
  105.  
  106. // called by Lib.x when a key is entered in the dialog box
  107. function ondialog (keycode)
  108.   // macro help
  109.   if keycode == <f1> then
  110.     helpmacro macrofile
  111.   end
  112. end
  113.  
  114. // display the dialog box, passing return variables by reference
  115. if (getdialog ref control1 ref control2 ref control3
  116.               ref control4 ref control5) == 'Ok' then
  117.  
  118.   // create another dialog box to display the
  119.   // return values from getdialog
  120.   dialog "Dialog Box Return Values" 40 9 "c"
  121.   writeline
  122.   writeline " Listbox:       "  + control1 [17:15]
  123.   writeline " Edit Field 1:   " + control2
  124.   writeline " Edit Field 2:   " + control3
  125.   writeline " Check Boxes:    " + control4
  126.   writeline " Radio Buttons:  " + control5
  127.   button "O&k" 17  8 8
  128.   getdialog
  129.  
  130. end
  131.